const { Router } = require('express')
const express = require('express')
//路由容器
const safe = express.Router()
const axios = require('axios')
const { JsonWebTokenError } = require('jsonwebtoken')
const jwt = require("jsonwebtoken")
safe.put('/user/updatePassword', (req, res) => {
    console.log(req.body.params)
    let {userId,password,newPassword}=req.body.params
   axios({
       method:'put',
       url : '/user/updatePassword',
       headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        token:req.session.token
    },
       params:{
        userId:jwt.decode(req.session.token).id,
        password:password,
        newPassword:newPassword
    }
   }).then(function(data){
       res.status(200).json({
           data:data.data,
           code:0
       })
   }).catch(function(err){
       res.status(500).json({
           msg:err
       })
   })
})

module.exports=safe;